<!DOCTYPE html> 
<html>
	<head>
		<meta charset="UTF-8">
		<title>{$data.agent_name}</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../../wx/css/iconfont.css" />
		<link rel="stylesheet" href="../../wx/css/style.css" />
		<link rel="stylesheet" href="../../wx/css/new.css" /> 
		<link rel="stylesheet" href="../../css/mui.min.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		
	</head>
	<style>
		.jianjie img{
			margin-left: -10px;
		}
		.mui-bar-nav,.gerzl_btn a{
    	    background-color: #22ab39;
	    }
	</style>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">商家详情</h1>
		</header>
		<div class="mui-content" style="background: white; padding: 44px 0 0;" id='list'>
			<div class="sjp_top">
				<!--<div class="sjp_img"><img src="{$data.logo?$data.logo:'__PUBLIC__/static/index/images/noimage.jpg'}"></div>-->
				<div class="sjp_img"><img :src="agent.logo" id='imgs'></div>
				<div class="sjp_info">
					<p class="nam" id='agent_name'>{{agent.agent_name}}  </p>
					<p class="huod" id='action'>{{agent.action}} </p>
					<p class="time"><span class="iconfont icon-naozhong"></span> <span id='time'>{{agent.start_time}}~{{agent.end_time}}</p>
					<p class="tel"><span class="iconfont icon-shouji"></span><a href="javascript:vold()" id='mobile'>{{agent.mobile}} </a></p>
				</div>
			</div>
			<div class="sjp_dizbox">
				<div class="iconfont icon-dingwei1" style="width: 30px"></div>
				<div class="sjp_diz">
					<p class="diz"><a href="{:url('index/map',['lng'=>$data.longitude,'lat'=>$data.latitude,'name'=>$data.agent_name])}" ><span id='address'>{{agent.address}}</span> </a></p>
				</div> 
			</div> 
			<ul class="sjp_splist clearfix" >
				<li v-for="gd in items">
					<a href="goodsshow.html?goods_id={$gd.id}">
						<div class="sjp_spimg">
							<img style="height: 9.5rem;" :src="gd.thumb?gd.thumb:'../../images/noimage.jpg'">
							<div class="sjp_glj">可抵用<br/><em>{{gd.dk_price}}</em><br/>鼓励金</div>
						</div>
						<div class="sjp_spinfobox">
							<div class="sjp_spinfo">
								<p class="nam">{{gd.goods_name}}</p> 
							</div>
							<div class="sjp_pri">¥<em>{{gd.sale_price}}</em></div>
						</div>
					</a>
				</li> 
				
			</ul>
			<div style="margin-left: 20px;font-size: 1.2rem;font-weight: bold;margin-top: 10px;"> 商家简介： </div>
			<div style="margin-left: 20px;font-size: 1rem;font-weight: bold;color: #000000;" class="jianjie" id='content'>
				
			</div>
			<ul class="sjp_splist clearfix" id='shop_info' hidden="">
				<div class="spnone"><img src="../../wx/images/shop_info.png" style="margin-top: -60px;"></div>
			</ul>
		</div>
	</body>
	
	<script src="../../js/mui.js"></script>
	<script src="../../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/app.js"></script>
	<script src="../../js/m.js"></script>
	<script>
	  	mui.plusReady(function() {
            plus.nativeUI.showWaiting("加载中....",{padlock: true});//数据出来前显示等待加载框
            get_list();
      	});
      		
      	var news = new Vue({
				el: '#list',
				data: {
					agent:{},
					items: [] //列表信息流数据
				}
		});
      	function get_list(){
      		var agent_id = plus.webview.currentWebview().tid;
      		
      		var data={agent_id: agent_id};
			console.log(JSON.stringify(data));
			ajaxData(set.api_url+"Wx/agent_info",data,function(res){
				plus.nativeUI.closeWaiting();
				var goods=res.data.goods;
				var agent=res.data.agent;
				console.log(JSON.stringify(agent));
				if(goods && goods.length > 0) {
					news.agent=agent;
					news.items = news.items.concat(goods);
				}
				document.getElementById("agent_name").innerText=agent.agent_name;
				document.getElementById('action').innerText = agent.action;
				document.getElementById("time").innerText=agent.start_time+'~'+ agent.end_time;
				document.getElementById('mobile').innerText = agent.mobile;
				document.getElementById('imgs').src = agent.logo;
				document.getElementById('address').innerText = agent.address;
				document.getElementById('content').innerHTML = agent.content;
				
				if(agent.content == null){
					document.getElementById("shop_info").style.display="block";
				}
			});
      	}
      
		
		/**
		 * 1、将服务端返回数据，转换成前端需要的格式
		 * 2、若服务端返回格式和前端所需格式相同，则不需要改功能
		 * 
		 * @param {Array} items 
		 */
		function convert(items) {
			var newItems = [];
			items.forEach(function(item) {
				newItems.push({
					goods_name: item.goods_name,
					sale_price: item.sale_price,
					dk_price: item.dk_price,
					thumb: item.thumb
				});
			});
			return newItems;
		}

      	
			//监听自定义事件，获取新闻详情
//			document.addEventListener('get_detail', function(event) {
//				var id = event.detail.id;
//				console.log(222);
//				console.log(id);
//			});
	</script>
</html>
